Skip to content

BUG: serialize numpy SeedSequence for sensor seeds (#1087) - #1124

Merged
Gui-FernandesBR merged 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1087-sensor-seedsequence-serialize
Aug 15, 2026
Merged

BUG: serialize numpy SeedSequence for sensor seeds (#1087)#1124
Gui-FernandesBR merged 2 commits into
RocketPy-Team:developfrom
thatrandomasiandev:bug/1087-sensor-seedsequence-serialize

Conversation

@thatrandomasiandev

Copy link
Copy Markdown

Summary

  • Teach RocketPyEncoder / RocketPyDecoder to round-trip numpy.random.SeedSequence via its reconstructible state (entropy, spawn_key, n_children_spawned, pool_size) plus a class signature.
  • Fixes TypeError: Object of type SeedSequence is not JSON serializable when dumping sensors (or any object) that hold a SeedSequence seed, including spawned child sequences used for parallel Monte Carlo.

Fixes #1087

Test plan

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=. pytest -p pytest_cov tests/unit/sensors/test_sensor_seeding.py -q (8 passed)
  • Regression: Accelerometer(..., seed=SeedSequence(0).spawn(1)[0]) then json.dumps(sensor.to_dict(), cls=RocketPyEncoder) succeeds and decoder restores matching .state

@thatrandomasiandev
thatrandomasiandev requested a review from a team as a code owner August 11, 2026 01:33
@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/1087-sensor-seedsequence-serialize branch from c586fd2 to 118d866 Compare August 11, 2026 01:48
@Gui-FernandesBR Gui-FernandesBR linked an issue Aug 15, 2026 that may be closed by this pull request
@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/1087-sensor-seedsequence-serialize branch from 118d866 to 34679a2 Compare August 15, 2026 01:50
@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.33%. Comparing base (76cab5a) to head (db9e68e).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1124   +/-   ##
========================================
  Coverage    84.33%   84.33%           
========================================
  Files          130      130           
  Lines        17258    17266    +8     
========================================
+ Hits         14554    14562    +8     
  Misses        2704     2704           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gui-FernandesBR
Gui-FernandesBR force-pushed the bug/1087-sensor-seedsequence-serialize branch from 34679a2 to ee699b6 Compare August 15, 2026 02:28
The SeedSequence branch pushed object_hook to 26 statements, one over
pylint's max-statements, failing the Linters job. Extract the Flight
rebuild into a module-level helper next to set_minimal_flight_attributes,
matching how that path is already factored. Pure code move.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Gui-FernandesBR
Gui-FernandesBR merged commit 2ce0ad6 into RocketPy-Team:develop Aug 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sensor accepts a SeedSequence seed but cannot serialize it

2 participants